import 'package:flutter/material.dart';

class MyTags extends StatelessWidget {
  final String groupValue;
  final String title;
  final List options;
  final Function onChanged;
  final theme;
  const MyTags({
    super.key,
    required this.groupValue,
    required this.title,
    required this.options,
    required this.onChanged,
    required this.theme,
  });

  @override
  Widget build(BuildContext context) {
    return Wrap(
      spacing: 8,
      runSpacing: 8,
      children: [
        Padding(
          padding: const EdgeInsets.only(
            top: 5,
            bottom: 5,
          ),
          child: Text(
            '$title:',
            style: TextStyle(
              fontSize: 15.5,
              color: Colors.white,
              fontWeight: FontWeight.bold,
            ),
          ),
        ),
        for (var item in options)
          Material(
            // 圆角
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(3),
            ),
            color: groupValue == item[0]
                ? theme.primary
                : Colors.white.withOpacity(0.2),
            clipBehavior: Clip.antiAlias,
            child: InkWell(
              onTap: () {
                onChanged(item[0]);
              },
              child: Padding(
                padding: const EdgeInsets.only(
                  left: 10,
                  right: 10,
                  top: 5,
                  bottom: 5,
                ),
                child: Text(
                  item[1],
                  style: TextStyle(
                    color: Colors.white,
                  ),
                ),
              ),
            ),
          ),
      ],
    );
  }
}
